package com.zengqingfa.dubbo.mall.service;

import com.google.common.collect.Lists;
import com.zengqingfa.dubbo.mall.entity.UserAddress;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 *
 * @fileName: OrderServiceStub
 * @author: zengqf3
 * @date: 2021-4-12 15:02
 * @description:
 */
@Slf4j
public class UserServiceStub implements UserService {

    private final UserService userService;

    // 构造函数传入真正的远程代理对象
    public UserServiceStub(UserService userService) {
        this.userService = userService;
    }

    @Override
    public List<UserAddress> getUserAddressList(String userId) {
        // 此代码在客户端执行, 你可以在客户端做ThreadLocal本地缓存，或预先验证参数是否合法，等等
        try {
            log.info("UserServiceStub 调用");
            return userService.getUserAddressList(userId);
        } catch (Exception e) {
            // 你可以容错，可以做任何AOP拦截事项
            return Lists.newArrayList();
        }
    }
}
